package com.bss.service;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.andy.basics.Dao;
import com.bss.dao.BuildingDao;
import com.bss.model.Building;

@Service
public class BuildingService extends com.andy.basics.Service<Building> {

	private static final Logger LOGGER = Logger.getLogger(BuildingService.class.getName());

	@Autowired
	protected BuildingDao buildingDao;

	@Override
	public Dao<Building> getDao() {
		return this.buildingDao;
	}

	public void setBuildingDao(final BuildingDao buildingDao) {
		this.buildingDao = buildingDao;
	}

	@Transactional
	public List<Building> getBuildings() {
		final List<Building> buildings = this.buildingDao.findAll();
		for (Building b : buildings) {
			b.getRooms().size();
		}
		return buildings;
	}

}
